<table id="dg-admin" style="height:100%">
	<thead>
		<tr>
			<th data-options="field:'ck',checkbox:true"></th>
			<th data-options="field:'itemid',width:80" sortable="true">Item ID</th>
			<th data-options="field:'productid',width:100" sortable="true">Product</th>
			<th data-options="field:'listprice',width:80,align:'right'" sortable="true">List Price</th>
			<th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
			<th data-options="field:'attr1',width:220">Attribute</th>
			<th data-options="field:'status',width:60,align:'center'">Status</th>
		</tr>
	</thead>
</table>

<div id="tb-admin">
	<table cellpadding="0" cellspacing="0" style="width:100%">
		<tr>
			<td style="float:left;padding:0 10px 0 0;">
				<a href="#" class="easyui-linkbutton button-blue" plain="true" onclick="admin_tool.add();"><i class="fa fa-plus fa-lg"></i> 添加</a>
				<a href="#" class="easyui-linkbutton button-teal" plain="true" onclick="admin_tool.edit();"><i class="fa fa-edit fa-lg"></i> 修改</a>
				<a href="#" class="easyui-linkbutton button-red" plain="true" onclick="admin_tool.edit();"><i class="fa fa-close fa-lg"></i> 删除</a>
			</td>
			<td style="float:left;padding:0 10px;">
                <div class="datagrid-btn-separator"></div>
            </td>
			<td style="float:left;padding:0 10px;">
				<a href="#" class="easyui-linkbutton button-black" plain="true" onclick="admin_tool.refresh();"><i class="fa fa-refresh fa-lg"></i> 刷新</a>
            </td>
		</tr>
	</table>
</div>

<div id="add-admin" style="display: none;">
	<form method="post" class="luck-from">
		<div class="group-label">
			<input class="easyui-validatebox" data-options="required:'true'">
		</div>
		<div class="group-label">
			<input class="easyui-validatebox" data-options="">
		</div>
	</form>
</div>
<div id="edit-admin"></div>

<div id="button-admin" style="display: none;">
	<a href="#" class="easyui-linkbutton button-blue" plain="true" onclick="admin_tool.add_save();"><i class="fa fa-check fa-lg"></i> 添加</a>
	<a href="#" class="easyui-linkbutton button-line-black" plain="true" onclick="admin_tool.add_close();"><i class="fa fa-close fa-lg"></i> 取消</a>
</div>

<script>
$(function(){
	$('#dg-admin').datagrid({
		url:'json/datagrid_data1.json',
		method:'get',
		sortName:'itemid',	//选择字段排序
		sortOrder:'desc',	//默认排序的方式 asc/desc
		pagination:true,	//开启分页
		pageSize:20,	//默认分页数
		pageList:[10,20,50,100],	//分页模式
		selectOnCheck:true,
		checkOnSelect:true,	//点击行选中
		singleSelect:false,	//多选
		loadMsg:'Processing, please wait…',
		striped:true,	//添加斑马线
		fitColumns:true,
		toolbar: '#tb-admin',
	});
});

var admin_tool={
	add:function(){
		$('#add-admin').dialog({
		    title: 'Add',    
		    width: 500,    
		    height:600,    
		    closed: false,    
		    cache: false,
		    cls:'theme-panel-deepblue',
		    buttons:'#button-admin',
		    modal: true
		});
		//清除关闭数据没清空问题
		$('#add-admin form').form('clear');
	},
	refresh:function(){
		luck.refresh('#add-admin');
	},
	add_close:function(){
		$('#add-admin').dialog('close');
	},
	add_save:function(){
		$('#add-admin form').form('submit',{
			url:"1",
			onSubmit:function(){
				var isValid = $(this).form('validate');
				return isValid;
			},
			success:function(data){
				$.messager.alert('Info', '1', 'info');
			}
		})
	}
}
</script>